package com.devbobcorn.nekoration.client.rendering.chunks;

import java.util.List;
import java.util.Set;

import javax.annotation.Nullable;

import com.google.common.collect.Lists;

import it.unimi.dsi.fastutil.objects.ObjectArraySet;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.chunk.SetVisibility;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class CompiledModelChunk {
	public static final CompiledModelChunk UNCOMPILED = new CompiledModelChunk() {
		public boolean facesCanSeeEachother(Direction dir1, Direction dir2) {
			return false;
		}
	};
	public final Set<RenderType> hasBlocks = new ObjectArraySet<>();
	public final Set<RenderType> hasLayer = new ObjectArraySet<>();
	public boolean isCompletelyEmpty = true;
	public final List<TileEntity> renderableBlockEntities = Lists.newArrayList();
	public SetVisibility visibilitySet = new SetVisibility();
	@Nullable
	public BufferBuilder.State transparencyState;

	public boolean hasNoRenderableLayers() {
		return this.isCompletelyEmpty;
	}

	public boolean isEmpty(RenderType type) {
		return !this.hasBlocks.contains(type);
	}

	public List<TileEntity> getRenderableBlockEntities() {
		return this.renderableBlockEntities;
	}

	public boolean facesCanSeeEachother(Direction dir1, Direction dir2) {
		return this.visibilitySet.visibilityBetween(dir1, dir2);
	}
}